package com.cow.support.remote;

import java.net.MalformedURLException;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.caucho.hessian.client.HessianProxyFactory;
/**
 * Hessian客户端
 * 
 * @author yangsj
 **/
@Component
public class HessianClient {
	private AuthRemoteService authService;
	@Value("${auth.url}")
	private String url;
	private void init()
	{  
		if(authService == null){
			HessianProxyFactory factory = new HessianProxyFactory();   
	        try {
				authService = (AuthRemoteService) factory.create(AuthRemoteService.class, url);
			} catch (MalformedURLException e) {
				e.printStackTrace();
			}  
		}
       
    }  
	
	public AuthRemoteService getClient(){   
		init();
        return authService;
    } 
}
